package com.wangzhy.financial.controller;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.wangzhy.financial.domain.XmInfo;
import com.wangzhy.financial.service.IXmInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 项目信息Controller
 *
 * @author wangzhy
 * @date 2021-11-15
 */
@RestController
@RequestMapping("/financial/xmInfo")
@Api(tags = "项目信息")
public class XmInfoController extends BaseController
{
    @Autowired
    private IXmInfoService xmInfoService;

    /**
     * 查询项目信息列表
     */
    @ApiOperation("查询项目信息列表")
    @PreAuthorize("@ss.hasPermi('financial:xmInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(XmInfo xmInfo)
    {
        startPage();
        List<XmInfo> list = xmInfoService.selectXmInfoList(xmInfo);
        return getDataTable(list);
    }

    /**
     * 导出项目信息列表
     */
    @ApiOperation("导出项目信息列表")
    @PreAuthorize("@ss.hasPermi('financial:xmInfo:export')")
    @Log(title = "项目信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(XmInfo xmInfo)
    {
        List<XmInfo> list = xmInfoService.selectXmInfoList(xmInfo);
        ExcelUtil<XmInfo> util = new ExcelUtil<XmInfo>(XmInfo.class);
        return util.exportExcel(list, "xmInfo");
    }

    /**
     * 获取项目信息详细信息
     */
    @ApiOperation("获取项目信息详细信息")
    @PreAuthorize("@ss.hasPermi('financial:xmInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(xmInfoService.selectXmInfoById(id));
    }

    /**
     * 新增项目信息
     */
    @ApiOperation("新增项目信息")
    @PreAuthorize("@ss.hasPermi('financial:xmInfo:add')")
    @Log(title = "项目信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XmInfo xmInfo)
    {
        return toAjax(xmInfoService.insertXmInfo(xmInfo));
    }

    /**
     * 修改项目信息
     */
    @ApiOperation("修改项目信息")
    @PreAuthorize("@ss.hasPermi('financial:xmInfo:edit')")
    @Log(title = "项目信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XmInfo xmInfo)
    {
        return toAjax(xmInfoService.updateXmInfo(xmInfo));
    }

    /**
     * 删除项目信息
     */
    @ApiOperation("删除项目信息")
    @PreAuthorize("@ss.hasPermi('financial:xmInfo:remove')")
    @Log(title = "项目信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(xmInfoService.deleteXmInfoByIds(ids));
    }
}
